#include "ResultBuffer.hpp"

ResultBuffer::ResultBuffer(int size, string namepattern)
{
  this->size = size;
  this->namepattern = namepattern + "-%d.mrout" ; 
  this->output = new ofstream[size]; 
  char filename[255]; 
  for (int i = 0; i < size; i++)
    {
      sprintf(filename, this->namepattern.c_str(), i);
      this->output[i].open(filename); 
    }
}

ResultBuffer::~ResultBuffer()
{
  for (int i = 0; i < this->size; i++)
    this->output[i].close(); 
  delete [] this->output; 
}

void ResultBuffer::addEntry(int r, pair<string, string> p)
{
  this->output[r] << p.first << ": " << p.second << endl << endl; 
}
